attribute vec4 position; 
attribute vec4 color; 
attribute vec4 normal;


uniform vec3 lightPos;			//	light position in world space
uniform mat4 modelViewMatrix;	//	
uniform mat4 projectionMatrix;	//	

varying vec4 pColor;		

//	the following variables are all in eye space
varying vec3 pNormal;			//	normal vector
varying vec3 pEyeVec;			//	the point to eye
varying vec3 lightDir;			//	the point to light

void main()
{ 
	pColor = color; 

	mat4 normalMatrix = transpose(inverse(modelViewMatrix));		//	inverse transpose matrix of modelViewMatrix
	pNormal = normalMatrix * normal;
	vec4 vVertex = modelViewMatrix * position;
	pEyeVec = -vVertex.xyz;									//	eye is at (0, 0, 0)
	lightDir = lightPos - vVertex.xyz;

	gl_Position = projectionMatrix * modelViewMatrix * position;
}
